package com.kuanter.kuanterauto.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;


public class WebSiteInfoList {
	
	/**
	 * 
	 */
	public static final String TAG="CardInfoList";
	
	private List<WebSiteInfo> shopinfos=null;
	
//	"shopInfoList": [
//	                 {
//	                     "id": 338,
//	                     "landmark": "碧水晴天",
//	                     "picAddr": "\/resources\/shopPicture\/1810800027_shopPic.jpg",
//	                     "queueingProbability": 1,
//	                     "serviceInfoList": [
//	                         {
//	                             "price": 17.00,
//	                             "priceType": 2,
//	                             "serviceId": 1895,
//	                             "serviceName": "小型车清洗"
//	                         },
//	                         {
//	                             "price": 25.00,
//	                             "priceType": 4,
//	                             "serviceId": 1895,
//	                             "serviceName": "小型车清洗"
//	                         },
//	                         {
//	                             "price": 20.00,
//	                             "priceType": 2,
//	                             "serviceId": 1896,
//	                             "serviceName": "大型车清洗"
//	                         },
//	                         {
//	                             "price": 30.00,
//	                             "priceType": 4,
//	                             "serviceId": 1896,
//	                             "serviceName": "大型车清洗"
//	                         }
//	                     ],
//	                     "serviceList": [
//	                         {
//	                             "cashPrice": 25.00,
//	                             "facePrice": 17.00,
//	                             "id": 1895,
//	                             "serviceName": "小型车清洗"
//	                         },
//	                         {
//	                             "cashPrice": 30.00,
//	                             "facePrice": 20.00,
//	                             "id": 1896,
//	                             "serviceName": "大型车清洗"
//	                         }
//	                     ],
//	                     "shopAddress": "琴台大道736号",
//	                     "shopName": "凯之隆汽车美容服务中心",
//	                     "shopNumber": "1810702004",
//	                     "shopPhone": "13307115507",
//	                     "shortName": "凯之隆",
//	                     "xCoordinates": "114.230843",
//	                     "yCoordinates": "30.574512"
//	                 },

	public WebSiteInfoList(String json){
		try {
			JSONObject jobj=new JSONObject(json);
			JSONArray jarr=jobj.optJSONArray("shopInfoList");
			shopinfos=new ArrayList<WebSiteInfo>();
			for(int i=0;i<jarr.length();i++){
				JSONObject jo=jarr.optJSONObject(i);
				WebSiteInfo shopinfo=new WebSiteInfo();
			    
				shopinfo.setShopName(jo.optString("shopName"));
				shopinfo.setShopAddress(jo.optString("shopAddress"));
				shopinfo.setShopPhone(jo.optString("shopPhone"));
				shopinfo.setShopImage(jo.optString("picAddr"));
				shopinfo.setxCoordinates(jo.optString("xCoordinates"));
				shopinfo.setyCoordinates(jo.optString("yCoordinates"));
				shopinfo.setQueue(jo.optString("queueingProbability"));
				
				
				
				JSONArray ja=jo.optJSONArray("serviceList");
				for(int j=0;j<ja.length();j++){
					JSONObject o=ja.optJSONObject(j);
//					if((o.optString("serviceName").equals("小型车清洗"))&&(o.optString("priceType").equals("2")))
//					{
//						shopinfo.setSmallcarPoint(o.optString("price"));
//					}
//					else if((o.optString("serviceName").equals("小型车清洗"))&&(o.optString("priceType").equals("4")))
//					{
//						shopinfo.setSmallcarPrice(o.optString("price"));
//					}
//					else if((o.optString("serviceName").equals("大型车清洗"))&&(o.optString("priceType").equals("2")))
//					{
//						shopinfo.setBigcarPoint(o.optString("price"));
//					}
//					else if((o.optString("serviceName").equals("大型车清洗"))&&(o.optString("priceType").equals("4")))
//					{
//						shopinfo.setBigcarPrice(o.optString("price"));
//					}
					
					if((o.optString("serviceName").equals("小型车清洗")))
					{
						shopinfo.setSmallcarPrice(o.optString("cashPrice"));
						shopinfo.setSmallcarPoint(o.optString("facePrice"));
					}else if((o.optString("serviceName").equals("大型车清洗")))
					{
						shopinfo.setBigcarPrice(o.optString("cashPrice"));
						shopinfo.setBigcarPoint(o.optString("facePrice"));
					}
					
				}
				
//				System.out.println(shopinfo.getSmallcarPoint()+"-"+shopinfo.getSmallcarPrice()+
//						"-"+shopinfo.getBigcarPoint()+"-"+shopinfo.getBigcarPrice());
				
				shopinfos.add(shopinfo);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	public List<WebSiteInfo> getWebSiteInfos() {
		return shopinfos;
	}


	
	
	
}
